<template>
  <PageWrapper :title="getTitle" @back="goBack">
    <Description @register="register" class="mt-4" />
    <div class="p-0">
      <BasicTable
        title="奖级配置"
        :columns="columns"
        :dataSource="levels"
        :canResize="false"
        :loading="false"
        :striped="false"
        :bordered="false"
        :showIndexColumn="false"
        :pagination="false"
      ></BasicTable>
    </div>
  </PageWrapper>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { getTicketApi } from '@/api/core/ticket.api';
import { Description, useDescription } from '@/components/Description';
import {detailSchema, dict, getBasicColumns} from './ticket.data';
import { useRoute } from 'vue-router';
import { TicketIndexGo } from '@/enums/core/ticket.enum';
import { useTabs } from '@/hooks/web/useTabs';
import { PageWrapper } from '@/components/Page';
import { useUserStore } from '@/store/modules/user';
import { DescItemSizeEnum } from '@/enums/basic';
import {LevelLM} from "@/model/core/level.model";
import { BasicTable } from '@/components/Table';
import {dictConversion} from "@/utils/scratch";
const route = useRoute();
const { setTitle } = useTabs();
const getTitle = ref('票信息管理详情');

const columns = getBasicColumns();
const levels = ref<LevelLM>([]);
const [register, { setDescProps }] = useDescription({
  title: '票信息管理详情',
  schema: detailSchema,
  column: DescItemSizeEnum.DEFAULT,
});
onMounted(async () => {
  const id = route.params.id as string;
  const data = await getTicketApi(id);
  setDescProps({ data: data });
  getTitle.value = '票信息管理详情:' + data?.playName;
  setTitle(getTitle.value);
  let dataNew = [];
  data.levels.map(item => {
    let obj = {
      name: dictConversion(dict.DicBaseTicketAwardLevelNameOptions, item.name),
      winMoney: item.winMoney,
      winNum: item.winNum,
    }
    dataNew.push(obj);
  });
  levels.value = dataNew;
});

/** 返回票信息管理主页 */
function goBack() {
  useUserStore().getRoutePath(TicketIndexGo);
}



</script>
